package com.minimalist.lindi.controller;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationfile.LindiSubsidyApplicationFileQueryVO;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationfile.LindiSubsidyApplicationFileVO;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import com.minimalist.lindi.service.LindiSubsidyApplicationFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地指标交易平台_补贴申请文件控制器
 *
 * @author 11987
 */
@Validated
@RestController
@Tag(name = "林地指标交易平台_补贴申请文件管理")
@RequestMapping("/lindi/subsidyApplicationFile")
public class LindiSubsidyApplicationFileController{

    @Autowired
    private LindiSubsidyApplicationFileService service;

    @PostMapping("/addSubsidyApplicationFile")
    @Operation(summary = "添加补贴申请文件")
    public R<?> addSubsidyApplicationFile(
            @RequestBody @Validated(Add.class)
            LindiSubsidyApplicationFileVO subsidyApplicationFileVO){
        service.addSubsidyApplicationFile(subsidyApplicationFileVO);
        return R.ok();
    }

    @DeleteMapping("/deleteSubsidyApplicationFileBySubsidyApplicationFileId")
    @Operation(summary = "删除补贴申请文件 -> 根据补贴申请文件ID删除")
    public R<?> deleteSubsidyApplicationFileBySubsidyApplicationFileId(
            @RequestParam("subsidyApplicationFileId")
            @NotNull(message = "补贴申请文件ID不能为空")
            @Parameter(name = "subsidyApplicationFileId", required = true, description = "补贴申请文件ID")
            Long subsidyApplicationFileId){
        service.deleteSubsidyApplicationFileBySubsidyApplicationFileId(subsidyApplicationFileId);
        return R.ok();
    }

    @PutMapping("/updateSubsidyApplicationFileBySubsidyApplicationFileId")
    @Operation(summary = "修改补贴申请文件")
    public R<?> updateSubsidyApplicationFileBySubsidyApplicationFileId(
            @RequestBody @Validated(Update.class)
            LindiSubsidyApplicationFileVO subsidyApplicationFileVO){
        service.updateSubsidyApplicationFileBySubsidyApplicationFileId(subsidyApplicationFileVO);
        return R.ok();
    }

    @GetMapping("/getPageSubsidyApplicationFileList")
    @Operation(summary = "查询补贴申请文件列表(分页)")
    public R<PageResp<LindiSubsidyApplicationFileVO>> getPageSubsidyApplicationFileList(
            @RequestBody LindiSubsidyApplicationFileQueryVO queryVO){
        return R.ok(service.getPageSubsidyApplicationFileList(queryVO));
    }

    @GetMapping("/getSubsidyApplicationFileBySubsidyApplicationFileId/{subsidyApplicationFileId}")
    @Operation(summary = "根据补贴申请文件ID查询补贴申请文件")
    public R<LindiSubsidyApplicationFileVO> getSubsidyApplicationFileBySubsidyApplicationFileId(
            @PathVariable(value = "subsidyApplicationFileId")
            @NotNull(message = "补贴申请文件ID不能为空")
            @Parameter(name = "subsidyApplicationFileId", description = "补贴申请文件ID", required = true)
            Long subsidyApplicationFileId){
        return R.ok(service.getSubsidyApplicationFileBySubsidyApplicationFileId(subsidyApplicationFileId));
    }

    @GetMapping("/getSubsidyApplicationFileListBySubsidyApplicationId/{subsidyApplicationId}")
    @Operation(summary = "根据补贴申请ID查询文件列表")
    public R<PageResp<LindiSubsidyApplicationFileVO>> getSubsidyApplicationFileListBySubsidyApplicationId(
            @PathVariable(value = "subsidyApplicationId")
            @NotNull(message = "补贴申请ID不能为空")
            @Parameter(name = "subsidyApplicationId", description = "补贴申请ID", required = true)
            Long subsidyApplicationId){
        return R.ok(service.getSubsidyApplicationFileListBySubsidyApplicationId(subsidyApplicationId));
    }
}